
import ApiService from '../axios';
import type * as ConfigApiType from './configCenter.d';


export function lesionSearch(model: any) {
  return ApiService.post(
    '/config/lesion/search',
    model
  );
}


export function configLesion(model: any) {
  return ApiService.post(
    '/config/lesion',
    model
  );
}

export function lesionMaxCode(model: any) {
  return ApiService.get(
    '/config/lesion/maxCode',
    model
  );
}


export function toolSearch(model: any) {
  return ApiService.post(
    '/config/tool/search',
    model
  );
}


export function toolEdit(model: any) {
  return ApiService.put(
    '/config/tool',
    model
  );
}

export const searchLesionData = async (params: ConfigApiType.GetLesionParams) => {
  const data = await ApiService.post<ConfigApiType.GetLesionResponse>('/config/lesion/search', params)
  return data;
}

export const getLesionData = async (params: ConfigApiType.GetLesionParams) => {
  const { data } = await ApiService.post<ConfigApiType.GetLesionResponse>('/config/lesion/group/search', params)
  return data;
}

export const getToolData = async (params: ConfigApiType.GetToolDataParams) => {
  const { data } = await ApiService.post<ConfigApiType.GetToolDataResponse>('/config/tool/search', params)
  return data;
}

export const getCompData = async (params: ConfigApiType.GetCompDataParams) => {
  const { data } = await ApiService.post<ConfigApiType.GetCompDataResponse>('/config/component/search', params)
  return data;
}

export const getLabelData = async (params: ConfigApiType.GetLabelDataParams) => {
  const { data } = await ApiService.post<ConfigApiType.GetLabelDataResponse>('/config/common/search', params);
  return data;
}

export const addLabelChild = async (params: ConfigApiType.AddLabelChildParams) => {
  const data = await ApiService.post<ConfigApiType.CommomResponse>('/config/common/child', params);
  return data;
}

export const updateLabelChild = async (params: ConfigApiType.UpdateLabelChildParams) => {
  const data = await ApiService.put<ConfigApiType.CommomResponse>('/config/common/child', params);
  return data;
}

export const getLabelMaxCode = async (params: ConfigApiType.GetLabelMaxCodeParams) => {
  const { data } = await ApiService.get<ConfigApiType.GetLabelMaxCodeResponse>(`/config/common/maxCode?codePrefix=${params.codePrefix}`);
  return data;
}

export const addLesion = async (params: ConfigApiType.AddLesionParams) => {
  const data = await ApiService.post<ConfigApiType.CommomResponse>('/config/lesion', params);
  return data;
}

export const updateLesion = async (params: ConfigApiType.UpdateLesionParams) => {
  const data = await ApiService.put<ConfigApiType.CommomResponse>('/config/lesion', params);
  return data;
}

export const getLesionMaxCode = async () => {
  const { data } = await ApiService.get<ConfigApiType.GetLabelMaxCodeResponse>('/config/lesion/maxCode');
  return data;
}

export const updateTool = async (params: ConfigApiType.UpdateToolParams) => {
  const data = await ApiService.put<ConfigApiType.CommomResponse>('/config/tool', params);
  return data;
}

export const getToolMaxCode = async () => {
  const { data } = await ApiService.get<ConfigApiType.GetLabelMaxCodeResponse>('/config/tool/maxCode');
  return data;
}

export const addComp = async (params: ConfigApiType.AddCompParams) => {
  const data = await ApiService.post<ConfigApiType.CommomResponse>('/config/component', params);
  return data;
}

export const updateComp = async (params: ConfigApiType.UpdateCompParams) => {
  const data = await ApiService.put<ConfigApiType.CommomResponse>('/config/component', params);
  return data;
}

export const viewComp = async (params: ConfigApiType.ViewCompParams) => {
  const { data } = await ApiService.get<ConfigApiType.ViewCompResponse>(`/config/component/${params.id}`);
  return data;
}

export const getExisted = async (params: ConfigApiType.ExistedParams) => {
  const data = await ApiService.post<ConfigApiType.ExistedResponse>('/config/common/name/existed', params);
  return data;
}